#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project: DataStructure-Python
@File: Bubble-Sort.py
@Author: Dragon Geek
@Date: 2021/4/19 10:15
@Description: Bubble Sort Algorithm
"""


def bubble_sort(list_unsorted):
    """
    @param list_unsorted: the list that is unsorted in bubble sort algorithm
    @return: the list that has be sorted in bubble sort algorithm
    """
    n = len(list_unsorted)
    for i in range(0, n - 1):
        count = 0
        for j in range(0, n - 1 - i):
            if list_unsorted[j] > list_unsorted[j + 1]:
                list_unsorted[j], list_unsorted[j + 1] = list_unsorted[j + 1], list_unsorted[j]
                count += 1
        if count == 0:
            return
            # return list_unsorted


if __name__ == "__main__":
    list_01 = [1, 2, 3, 4, 5, 6]
    print(list_01)
    bubble_sort(list_01)
    print(list_01)
